<%@page contentType="text/html" pageEncoding="UTF-8" %>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags/form" %>

<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/engine.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/script/jquery.form.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/script/json2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/script/questionSet/main.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/script/questionSet/QuestionSet.js"></script>

<script type="text/javascript">
    $(function() {
        $('form').enableContentChangedConfirm();
    });

    var formId = "questionSet";

    function editAction(target) {
        QuestionSet.actionBeforePost();
        afterSubmitRedirect(formId, "edit.html", target, "submitAction");
    }

    $(document).ready(function () {
        $("#saveBtn").click(function () {
            editAction("SUBMIT");
        });

        $("#saveAndExitBtn").click(function () {
            editAction("SUBMIT_AND_EXIT");
        });

        $("#saveAndNewBtn").click(function () {
            editAction("SUBMIT_AND_NEW");
        });

        $("#saveBtn2").click(function () {
            editAction("SUBMIT");
        });

        $("#saveAndExitBtn2").click(function () {
            editAction("SUBMIT_AND_EXIT");
        });

        $("#saveBtn3").click(function () {
            editAction("SUBMIT");
        });

        $("#saveAndExitBtn3").click(function () {
            editAction("SUBMIT_AND_EXIT");
        });
    });
</script>

<!-- Menu -->
<jsp:include page="menu.jsp"/>

<!--START: Subnav -->
<div class="sub_nav">
    <ul>
        <li>
            <a href="#" onclick="navToGeneral(); return false;">
                <img src="<%= request.getContextPath()%>/images/menu/sub_general_on.gif" alt="general"/>
            </a>
        </li>
        <li>
            <a href="#" onclick="navToQs(); return false;">
                <img src="<%= request.getContextPath()%>/images/menu/sub_questions_off.gif" alt="questions"/>
            </a>
        </li>
        <li>
            <a href="#" onclick="navToWhereUsed(); return false;">
                <img src="<%= request.getContextPath()%>/images/menu/sub_where_used_off.gif"
                     alt="whereUsed"/>
            </a>
        </li>
    </ul>
</div>
<!--END: Subnav -->

<!--START: conent -->
<div id="general" class="content2">
    <div class="insider">
        <div class="corners">
            <div class="corners_top"></div>

            <spring:form id="questionSet" modelAttribute="questionSet" method="post">

                <input type="hidden" id="submitAction" name="submitAction"/>
                <input type="hidden" id="questionsData" name="questions"/>
                <input type="hidden" id="questionsBak" name="questionsBak"/>
                <input type="hidden" id="questionListMsgBak" name="questionListMsgBak"/>
                <input type="hidden" id="from" name="from"/>

                <div class="column1">
                    <div class="col_l">
                        <table width="440" border="0" cellspacing="4" class="formlayout_table">
                            <tr>
                                <th width="188"><label>ID:</label></th>
                                <td width="240">${questionSet.refId}</td>
                            </tr>

                            <tr>
                                <th><label>Version:</label></th>
                                <td>${questionSet.version}</td>
                            </tr>
                            
                             <tr>
                                <th><label>Name:</label></th>
                                <td class="bg_n">
                                    <spring:input path="name" cssClass="input3" maxlength="255"/>
                                </td>
                            </tr>                           

                            <tr>
                                <th><label>Vocabulary Name:</label></th>
                                <td class="bg_n">
                                    <spring:input path="vocabularyname" cssClass="input3" maxlength="255"/>
                                </td>
                            </tr>

                           <tr>
                                <th><label>Text:</label></th>
                                <td class="bg_n">
                                    <spring:input path="text" cssClass="input3" maxlength="255"/>
                                </td>
                            </tr>

                            <tr>
                                <th><label>Display Title:</label></th>
                                <td class="bg_n">
                                    <spring:input id="displayTitleValue" path="displayTitle" cssClass="input3"
                                                  maxlength="255"/>
                                </td>
                            </tr>

                            <tr>
                                <th><label>Description:</label></th>
                                <td class="bg_n">
                                    <spring:textarea path="description" cssClass="textarea2"></spring:textarea>
                                </td>
                            </tr>

                            <tr>
                                <th><label>Help Text:</label></th>
                                <td class="bg_n">
                                    <spring:textarea path="helpText" cssClass="textarea2"></spring:textarea>
                                </td>
                            </tr>

                            <tr>
                                <th><label>Media URL:</label></th>
                                <td class="bg_n">
                                    <spring:input path="mediaUrl" cssClass="input3" maxlength="255"/>
                                </td>
                            </tr>
                        </table>
                    </div>
                    <table width="282" border="0" cellspacing="4" class="formlayout_table fr">
                        <tr>
                            <th width="159"><label>Sibling ID:</label>
                            </th>
                            <td width="111">
                                <c:if test="${not empty questionSet.sibling}">
                                    ${questionSet.sibling.refId}
                                </c:if>
                            </td>
                        </tr>
                        <tr>
                            <th><label>Sibling Version:</label></th>
                            <td>
                                <c:if test="${not empty questionSet.sibling}">
                                    ${questionSet.sibling.version}
                                </c:if>
                            </td>
                        </tr>
                        <tr>
                            <th><label>Status:</label></th>
                            <td>${questionSet.status.code}</td>
                        </tr>
                        <tr>
                            <th><label>Availability:</label></th>
                            <td>${questionSet.availability.code}</td>
                        </tr>
                        <tr>
                            <th><label>Last Modified Date:</label></th>
                            <td>
                                <fmt:formatDate value="${questionSet.modifiedOn}" pattern="dd-MMM-yyyy"/>
                            </td>
                        </tr>
                        <tr>
                            <th><label>Last Modified By:</label></th>
                            <td>${questionSet.modifiedBy.username}</td>
                        </tr>

                        <tr>
                            <th><label>Retired By:</label></th>
                            <td>${questionSet.retiredBy.username}</td>
                        </tr>

                        <tr>
                            <th><label>Retire Date:</label></th>
                            <td>${questionSet.retiredOn}</td>
                        </tr>

                        <tr>
                            <th><label>Retire Notes:</label></th>
                            <td>${questionSet.retiredNote}</td>
                        </tr>
                    </table>
                </div>
            </spring:form>

            <!-- Save, Save and Exit, Save and New, Cancel buttons -->
            <ul class="functions1">
                <li>
                    <a id="saveBtn" href="#">
                        <img src="<%= request.getContextPath()%>/images/btn/functions1/btn_save.gif" class="btn"/>
                    </a>
                </li>
                <li>
                    <a id="saveAndExitBtn" href="#">
                        <img src="<%= request.getContextPath()%>/images/btn/functions1/btn_save_exit.gif" class="btn"/>
                    </a>
                </li>
                <li>
                    <a id="saveAndNewBtn" href="#">
                        <img src="<%= request.getContextPath()%>/images/btn/functions1/btn_save_create_new.gif"
                             class="btn"/>
                    </a>
                </li>
                <li>
                    <jsp:include page="../common/qsCancelButton.jsp" />
                </li>
            </ul>

            <div class="corners_bottom"></div>
        </div>
        <div class="message">
            ${message}
            ${empty message ? '' : '<br />'}

            <jsp:include page="errorMessage.jsp"/>
        </div>
    </div>
</div>
<!--END: conent -->

<c:if test="${OPERATION == 'edit'}">
    <!-- Questions Tab Page -->
    <jsp:include page="editQuestions.jsp"/>

    <!-- WhereUsed Tab Page -->
    <jsp:include page="whereUsed.jsp"/>
</c:if>